package com.guchenbo.example.threadpool;

import java.util.concurrent.*;

/**
 * @Author gucb
 * @Date 2017/5/23.
 */
public class TimeoutTest {

    public static void main(String[] args) throws InterruptedException, ExecutionException, TimeoutException {
        ExecutorService executor = Executors.newSingleThreadExecutor();
        Future future = executor.submit(() -> {
            //do something

        });
        int timeout = 5000;
        future.get(timeout, TimeUnit.MILLISECONDS);
    }
}
